package io.renren.modules.sys.service.impl;

import java.util.Map;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.sys.dao.UserAmountDao;
import io.renren.modules.sys.entity.UserAmountEntity;
import io.renren.modules.sys.entity.UserOrderLogEntity;
import io.renren.modules.sys.service.UserAmountService;


@Service("userAmountService")
public class UserAmountServiceImpl extends ServiceImpl<UserAmountDao, UserAmountEntity> implements UserAmountService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<UserAmountEntity> page = this.selectPage(
                new Query<UserAmountEntity>(params).getPage(),
                new EntityWrapper<UserAmountEntity>()
        );

        return new PageUtils(page);
    }

	@Override
	public Integer queryUseAmount(Long userId) {
		Integer count = baseMapper.findUseAmount(userId);
		if(count == null)return 0;
		return count;
	}

	@Override
	public void updateUseAmount(UserOrderLogEntity param) {
		baseMapper.updateUseAmount(param);
	}

}
